var app=new Vue({
    el: '#app',
    data:{
        dict:{},
        isDisabled: false,
        dicts:{
            visible:  jsmile.copy([],jsmile.dict.sf),
            addable: jsmile.copy([],jsmile.dict.sf)
        },
        dictRules:   {
            dictCode: [
                { validator: validateDictCode, trigger: 'blur' }
            ],
            dictName: [
                { required: true, message: '请输入字典值名称', trigger: 'blur' }
            ],
            dictValue: [
                {  message: '请输入字典值值', trigger: 'blur' }
            ],
            visible: [
                { required: true, message: '请选择是否可见', trigger: 'change' }
            ],
            addable: [
                { required: true, message: '请选择是否可新增', trigger: 'change' }
            ],
            remark: [
                { max:100, message: '备注最大长度为100', trigger: 'blur' }
            ]
        }
    },
    methods:{
        init: function(){

        },
        closeDialog: function(){
            jsmile.dialog.close();
        },
        updateDict: function(){
            var _this=this;
            _this.isDisabled=true;
            this.$refs['dict'].validate(function(valid){
                if (valid) {
                    jsmile.http.sendJson({
                        url:jsmile.url+"/sys/dict/update",
                        data:_this.dict
                    }).done(function(res){
                        top.$('#home')[0].contentWindow.app.findAll();
                        jsmile.msg.success("修改字典成功");
                        jsmile.dialog.close();
                    }).fail(function(res){
                        jsmile.msg.error(res.resMsg?res.resMsg:"修改字典失败!");
                    });
                } else {
                    return false;
                }
            });
        }
    }
});
$(function(){
    init();
    function init(){
        app.init();
    }
});